package com.snail.controller;

import com.snail.model.vo.user.ThirdPartyUserInfoVO;
import com.snail.result.Result;
import com.snail.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Date 2025/8/18 19:58
 * @Author yangming
 * @Description 根据用户id查询用户用户
 **/
@RestController
@RequestMapping("/videoUser")
public class SysUserController {

    @Autowired
    private SysUserService sysUserService;

    /**
     * 根据用户ID查询用户名
     * @param userId 用户ID
     * @return 用户名结果
     */
    @GetMapping("/username")
    public Result<ThirdPartyUserInfoVO> getUsernameById(@RequestParam("userId") Long userId) {
        ThirdPartyUserInfoVO  thirdPartyUserInfoVO= sysUserService.getUsernameById(userId);
        if (thirdPartyUserInfoVO == null) {
            return Result.failed("用户不存在");
        }
        return Result.success(thirdPartyUserInfoVO);
    }
}
